# Build recipe for fluxbox.
#
# Copyright (C) 2017, MMPG <mmpg@vp.pl>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

program=fluxbox
version=1.3.7
release=1

tarname=${program}-${version}.tar.gz

# Remote source(s)
fetch=https://downloads.sourceforge.net/fluxbox/$tarname

description"
Fluxbox is a windowmanager for X that was based on the Blackbox 0.61.1 code.
It is very light on resources and easy to handle but yet full of features to make an easy, 
and extremely fast, desktop experience.
"

homepage=http://fluxbox.org/
license="MIT License"

# Source documentation
docs="AUTHORS COPYING ChangeLog NEWS README TODO"
docsdir="${docdir}/${program}-${version}"

build()
{
    set -e
    unpack "${tardir}/$tarname"
    
    cd "$srcdir"
    
    ./configure CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
    $configure_args \
    --mandir=/usr/man \
    --infodir=/usr/info \
    --enable-xinerama \
    --enable-slit \
    --enable-nls \
    --enable-timedcache \
    --enable-xext \
    --build="$(cc -dumpmachine)"
    
    make -j${jobs}
    make -j${jobs} DESTDIR="$destdir" install
    
    # Create fluxbox.desktop for support by display managers
    mkdir -pv "$destdir"/usr/share/xsessions
    cat $CWD/fluxbox.desktop > "$destdir"/usr/share/xsessions/fluxbox.desktop

    # Create configuration files
    mkdir -v ~/.fluxbox
    cp -v "$destdir"/usr/share/fluxbox/init ~/.fluxbox/init
    cp -v "$destdir"/usr/share/fluxbox/keys ~/.fluxbox/keys
    
    # Create menu
    cp -v "$destdir"/usr/share/fluxbox/menu ~/.fluxbox/menu
    
    # Copy documentation
    mkdir -p "${destdir}${docsdir}"
    
    for file in $docs
    do 
        cp -p $file "${destdir}${docsdir}"
    done
}